﻿using System;
using System.Collections.ObjectModel;

namespace FlickrXplorer.Web.Plugin
{
  /// <summary>
  /// Holds a collection of plugins.
  /// </summary>                    
  public class FlickrXplorerPluginCollection : KeyedCollection<string, FlickrXplorerPlugin>
  {
    protected override string GetKeyForItem(FlickrXplorerPlugin item)
    {
      return item.Name;
    }

    /// <summary>
    /// A helper method for applying a function to each element in
    /// the <see cref="FlickrXplorer.Web.Plugin.FlickrXplorerPluginCollection" text="collection" />.
    /// </summary>
    /// <param name="action">The Action&lt;FlickrXplorerPlugin&gt;to
    ///                      execute on each plugin.</param>                                        
    public void Foreach(Action<FlickrXplorerPlugin> action)
    {
      foreach (FlickrXplorerPlugin plugin in this)
      {
        action(plugin);
      }
    }
  }
}
